package com.itcast.flink.screen.database.bo;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

/**
 * <p>Description: </p>
 * @date  
 * @author   
 * @version 1.0
 * @name   
 * <p>Copyright:Copyright(c)2020</p>
 */
@Data
@NoArgsConstructor
@Document(indexName = "screen_dimension",type = "hotDimensionOrder", shards = 1, replicas = 0)
public class HotDimensionOrder {

    @Id
    private String id;

    public HotDimensionOrder(JoinOrderAddress order, Long timeWindow) {
        this.id = order.getProvince();
        this.goodsId = order.getGoodsId();
        this.goodsName = order.getGoodsName();
        this.totalAmount = order.getTotalAmount()/100;
        this.province = order.getProvince();
        this.city = order.getCity();
        this.createDate = new Date();
        this.timeWindow = timeWindow;
    }

    /**
     * 省份
     */
    @Field(type = FieldType.Keyword)
    private String province;

    /**
     * 城市
     */
    @Field(type = FieldType.Keyword)
    private String city;

    /**
     * 商品ID
     */
    @Field(type = FieldType.Keyword)
    private Long goodsId;

    /**
     * 商品名称
     */
    @Field(type = FieldType.Text)
    private String goodsName;

    /**
     * 总成交金额
     */
    @Field(type = FieldType.Long)
    private Long totalAmount;

    /**
     * 时间窗
     */
    @Field(type = FieldType.Long)
    private Long timeWindow;

    /**
     * 数据创建时间
     */
    @Field(type = FieldType.Date)
    private Date createDate;

}
